package com.astrofizzbizz.stoneedgegui.monitor;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.astrofizzbizz.stoneedgegui.app.WaitFrame;




public class DomeMonitorPanelActionListeners implements ActionListener
{

	private String actionString = "";
	private DomeMonitorPanel domeMonitorPanel;
	public DomeMonitorPanelActionListeners(String actionString, DomeMonitorPanel domeMonitorPanel)
	{
		this.actionString = actionString;
		this.domeMonitorPanel = domeMonitorPanel;
	}
	@Override
	public void actionPerformed(ActionEvent actionEvent) 
	{
		if (actionString.equals("Dome.Light.On")) 
		{
			domeMonitorPanel.getDomeLightControl().lightSwitch(true);
		}
		if (actionString.equals("Dome.Light.Off")) 
		{
			domeMonitorPanel.getDomeLightControl().lightSwitch(false);
		}
		if (actionString.equals("Dome.Open")) 
		{
			domeMonitorPanel.openDome();
		}
		if (actionString.equals("Dome.Close")) 
		{
			domeMonitorPanel.closeDome();
		}
		if (actionString.equals("Camera.Up")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("up");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera Up");
		}
		if (actionString.equals("Camera.Down")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("down");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera Down");
		}
		if (actionString.equals("Camera.Left")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("left");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera Left");
		}
		if (actionString.equals("Camera.Right")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("right");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera Right");
		}
		if (actionString.equals("Camera.ZoomOut")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("zoomOut");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera Out");
		}
		if (actionString.equals("Camera.ZoomIn")) 
		{
			domeMonitorPanel.getAxisCameraPanel().moveCamera("zoomIn");
			domeMonitorPanel.getTelescopeMonitorPanel().getStatusBar().setText("Moved Camera In");
		}
		if (actionString.equals("Lock.Changed"))
		{
			WaitFrame waitFrame = new WaitFrame("Wait", "Please wait. Updating Lock", domeMonitorPanel.getTelescopeMonitorPanel().getStoneEdgeIIIGui());
			domeMonitorPanel.getDomeMonitor().updateMonitor();
			if(actionEvent.getActionCommand().equals("locked")) 
			{
				if ( domeMonitorPanel.getTelescopeMonitorPanel().getStoneEdgeIIIGui().getUserKey().equals(domeMonitorPanel.getDomeMonitor().getTreffersLock().getSessionID()))
				{
					domeMonitorPanel.getDomeControlPanel().setVisible(true);
				}
			}
			if(actionEvent.getActionCommand().equals("unlocked")) 
			{
				domeMonitorPanel.getDomeControlPanel().setVisible(false);
			}
			waitFrame.dispose();
		}
	}
	
}
